﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DelonixRegiaHMSys.Core.Services;
using DelonixRegiaHMSys.Infrastructure.Data;

namespace DelonixRegiaHMSys.UI.WebForms
{
    public partial class RetrieveGuestParticular : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGridView();
            }
        }
        private void BindGridView()
        {
            var gpservice = new gpServices(new EfGuestParticularQuery());
            GridViewGP.DataSource = gpservice.GetAll().ToList();
            GridViewGP.DataBind();
        }

        protected void UpdateButton_Click(object sender, EventArgs e)
        {
             string[] arg = new string[5];
             arg = ((LinkButton)sender).CommandArgument.ToString().Split(';');
             string guestID = arg[0];
             string guestLastName = arg[1];
             string guestFirstName = arg[2];
             string homeAddress = arg[3];
             string nationality = arg[4];
             string contactNum = arg[5];
             string emailAddress = arg[6];
             string mailAddress = arg[7];
 

             string querystring = "Guest=" + guestID + "&GuestLastName=" + guestLastName + "&GuestFirstName=" + guestFirstName + "&HomeAddress=" + homeAddress + "&Nationality=" + nationality + "&ContactNumber" + contactNum + "&EmailAddress"+ emailAddress + "&MailAddress" + mailAddress ;
             Server.Transfer("~/WebForms/UpdateGuestParticular.aspx?" + querystring);
        }

        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            string guestID = (((LinkButton)sender).CommandArgument);
            var gpservice = new gpServices(new EfGuestParticularQuery());
            gpservice.DeleteGuest(guestID);
            BindGridView();
        }
    }
}